<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>

	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 10px !important;
}

.size {
	width: 550px;
	position: relative;
	left: 30%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>


	<title>Cadastro de Preço - Recomendação</title>
</h:head>

<h:body>

	<ui:decorate template="/templateBase.xhtml">

		<ui:define name="center">
			<p:growl id="growl" life="3000" autoUpdate="true" />
			<h:form prependId="true" id="formPreco">
				<br />
				<br />
				<br />
				<br />
				<p:panel header="Cadastro de Preço - Recomendação" styleClass="size"
					toggleable="true"
					footer="SIGLAS - Sistema de Gerenciamento de Laboratório de Análise de Solo">
					<br />
					<h:panelGrid columns="3">
						<h:outputText value="Recomendação:" />
						<p:inputText size="50" id="txtDeterminacao"
							value="#{recomendacaoPrecoBacking.recomendacaoPrecoSalvar.descricao}"
							required="true" requiredMessage="Informe a descrição!" />
						<p:commandButton icon="ui-icon-search" oncomplete="dlg.show()"
							actionListener="#{recomendacaoPrecoBacking.carregarPreco}"
							update=":formPesquisa:tabelaPreco" 	immediate="true" />

					</h:panelGrid>

					<h:panelGrid columns="2">

						<h:outputText value="Tipo de Cliente: " />

						<p:selectOneMenu effect="fade"
							value="#{recomendacaoPrecoBacking.tipoClienteSelecionado}"
							required="true" requiredMessage="Informe o tipo do cliente!">
							<f:selectItem itemDisabled="true" itemLabel="Selecione" />
							<f:selectItems
								value="#{recomendacaoPrecoBacking.listaTipoCliente}" />
						</p:selectOneMenu>


						<h:outputText value="Preço(R$):" />
						<p:inputText
							value="#{recomendacaoPrecoBacking.recomendacaoPrecoSalvar.preco}"
							maxlength="7" size="8" required="true"
							requiredMessage="Informe o preço da recomendação!" />

					</h:panelGrid>

					<br />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Salvar" icon="ui-icon-disk"
								action="#{recomendacaoPrecoBacking.salvar}" update=":formPreco" />

							<p:commandButton value="Cancelar" update=":formPreco"
								ajax="false" actionListener="#{recomendacaoPrecoBacking.reset}"
								icon="ui-icon-cancel" />
						</h:panelGrid>
					</div>
				</p:panel>
			</h:form>
			<h:form prependId="false" id="formPesquisa">
				<p:dialog id="pesquisaPreco" widgetVar="dlg"
					header="Pesquisar Preço" closable="true" height="400" width="400"
					resizable="false" showEffect="clip" hideEffect="clip">

					<p:dataTable var="r" id="tabelaPreco" paginator="true"
						value="#{recomendacaoPrecoBacking.listaRecomendacao}" rows="10"
						widgetVar="tabelaRecomendacao"
						emptyMessage="Nenhum registro foi encontrado, tente novamente!">
						<h:outputText value="Preço recomendações cadastradas" />

						<p:column headerText="Descrição" filterBy="#{r.descricao}">
							<h:outputText value="#{r.descricao}" />
						</p:column>

						<p:column headerText="Valor" filterBy="#{r.valor}">
							<h:outputText value="#{r.preco}" />
						</p:column>

						<p:column headerText="Ação">
							<p:commandButton value="Selecionar" onclick="dlg.hide()"
								update=":formPreco:txtDeterminacao" process="@this">
								<f:setPropertyActionListener value="#{d}"
									target="#{DeterminacaoPrecoBacking.determinacaoPrecoSalvar.determinacao}" />
							</p:commandButton>
						</p:column>

					</p:dataTable>
				</p:dialog>
				<p:dialog id="confirmaDelete" widgetVar="dlgDelete"
					header="Deletar Registro" closable="true" width="230"
					resizable="false" showEffect="clip" hideEffect="clip">
					<div align="center">
						<h:outputText value="Deseja realmente excluir esse registro?" />
						<h:panelGrid columns="2">
							<p:commandButton value="Sim" onsuccess="dlgDelete.hide()"
								actionListener="#{recomendacaoPrecoBacking.delete}"
								update=":formPesquisa:pesquisaPreco" process="@all"
								immediate="true" />
							<p:commandButton value="Não" onclick="dlgDelete.hide()" />
						</h:panelGrid>
					</div>
				</p:dialog>

			</h:form>

		</ui:define>
	</ui:decorate>
</h:body>
</html>